﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CustomsSystem.Model;
using CustomsSystem.DAL;
using System.Data;

namespace CustomsSystem.BLL
{
    public class WorkflowManage
    {
        public WorkflowService dal = new WorkflowService();
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CustomsSystem.Model.Info_workflow GetModel(int ID)
        {
            return dal.GetModel(ID);
        }

        public CustomsSystem.Model.Info_workflowMaster GetModelMaster(int ID)
        {
            return dal.GetModelMaster(ID);
        }

        public CustomsSystem.Model.Info_workflow GetModel(DataTable dt)
        {
            return dal.DataRowToModel(dt.Rows[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CustomsSystem.Model.Info_workflow> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        public List<CustomsSystem.Model.Info_workflowMaster> GetModelListMaster(string strWhere)
        {
            DataSet ds = dal.GetListMaster(strWhere);
            return DataTableToListMaster(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CustomsSystem.Model.Info_workflow> DataTableToList(DataTable dt)
        {
            List<CustomsSystem.Model.Info_workflow> modelList = new List<CustomsSystem.Model.Info_workflow>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CustomsSystem.Model.Info_workflow model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        public List<CustomsSystem.Model.Info_workflowMaster> DataTableToListMaster(DataTable dt)
        {
            List<CustomsSystem.Model.Info_workflowMaster> modelList = new List<CustomsSystem.Model.Info_workflowMaster>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CustomsSystem.Model.Info_workflowMaster model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModelMaster(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CustomsSystem.Model.Info_workflow model)
        {
            if (dal.Add(model)!=0) return true;
            else return false;
        }
        public int AddMaster(CustomsSystem.Model.Info_workflowMaster model)
        {
            return dal.AddMaster(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CustomsSystem.Model.Info_workflow model)
        {
            return dal.Update(model);
        }
        public bool UpdateMaster(CustomsSystem.Model.Info_workflowMaster model)
        {
            return dal.UpdateMaster(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {
            return dal.Delete(ID);
        }
        public bool DeleteMaster(int ID)
        {
            return dal.DeleteMaster(ID);
        }
    }
}
